package com.cskaoyan.service;

import com.cskaoyan.bean.MarketAdmin;
import com.cskaoyan.bean.MarketAdminExample;
import com.cskaoyan.bean.MarketUser;
import com.cskaoyan.bean.MarketUserExample;
import com.cskaoyan.mapper.MarketAdminMapper;
import com.cskaoyan.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author QHC
 * @title WxAuthServiceImpl
 * @date 2023/6/15 7:35
 * @description TODO
 */
@Service
public class WxAuthServiceImpl implements WxAuthSerrvice {
    @Autowired
    MarketUserMapper mapper;
    @Transactional

    public MarketUser query(String username, String password){


        MarketUserExample example = new MarketUserExample();
        example.createCriteria().andUsernameEqualTo(username).andPasswordEqualTo(password);
        List<MarketUser> marketAdmins = mapper.selectByExample(example);
        if (marketAdmins != null && marketAdmins.size() == 1) {
            return marketAdmins.get(0);
        }

        return null;
    }
}
